﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Shove.Web.UI;

public partial class UserControls_CustomerLogin : UCBase
{
    public UserControls_CustomerLogin()
    {
        Name = "用户登录";

        swpas = new ShoveWebPartAttribute[15];

        swpas[0] = new ShoveWebPartAttribute_Int("控件宽度", "1,1000", 221, "控件宽度");
        swpas[1] = new ShoveWebPartAttribute_Int("会员中心导航高", "1,300", 21, "会员中心导航高");
        swpas[2] = new ShoveWebPartAttribute_Image("会员中心导航背景图片1", "", "images/title_bg_2.jpg", "会员中心导航背景图片1");
        swpas[3] = new ShoveWebPartAttribute_Image("会员中心导航背景图片2", "", "images/title_bg_2_2.jpg", "会员中心导航背景图片2");
        swpas[4] = new ShoveWebPartAttribute_Text("导航CSS样式", "", "title14", "导航CSS样式");
        swpas[5] = new ShoveWebPartAttribute_Color("控件背景图片", "#E7C890", "控件背景图片");

        swpas[6] = new ShoveWebPartAttribute_Int("用户名行高", "1,400", 25, "用户名行高");
        swpas[7] = new ShoveWebPartAttribute_Int("用户名密码文本框宽度", "1,500", 120, "用户名密码文本框宽度");
        swpas[8] = new ShoveWebPartAttribute_Int("验证码输入框宽度", "1,300", 50, "验证码输入框宽度");
  
        swpas[9] = new ShoveWebPartAttribute_Text("用户名密码文字CSS样式", "", "black12", "用户名密码文字CSS样式");
        swpas[10] = new ShoveWebPartAttribute_Text("文本框CSS样式", "", "in_p2", "文本框CSS样式");
        swpas[11] = new ShoveWebPartAttribute_Text("忘记密码CSS样式", "", "black12", "忘记密码CSS样式");

        swpas[12] = new ShoveWebPartAttribute_Image("登陆按钮图片", "", "images/UserControls/user_button_1.jpg", "登陆按钮图片");
        swpas[13] = new ShoveWebPartAttribute_Image("新注册用户图片", "", "images/UserControls/user_button_2.jpg", "新注册用户图片");

        swpas[14] = new ShoveWebPartAttribute_PageNavigate("忘记密码链接页面", "Default.aspx?PN=forget", "忘记密码链接页面");
    }

    private void Initlayout()
    {
        tabctr.Width = swpAttributes[0];
        tabctr.BgColor = swpAttributes[5];
        //tdCenter.Style.Add("background-image", "url('" + swpAttributes[2] + "')");
        //tdCenter.Height = swpAttributes[1];
        //tdCenter.Attributes.Add("class", swpAttributes[4]);
        //tdCenter1.Style.Add("background-image", "url('" + swpAttributes[3] + "')");

        tdname.Height = swpAttributes[6];
        tdname.Attributes.Add("class", swpAttributes[9]);
        tdpsw.Height = swpAttributes[6];
        tdpsw.Attributes.Add("class", swpAttributes[9]);
        tdcode.Height = swpAttributes[6];
        tdcode.Attributes.Add("class", swpAttributes[9]);

        txtUserName.Width = new Unit(swpAttributes[7]);
        txtUserName.CssClass = swpAttributes[10];
        txtPassword.Width = new Unit(swpAttributes[7]);
        txtPassword.CssClass = swpAttributes[10];
        txtCode.Width = new Unit(swpAttributes[8]);
        txtCode.CssClass = swpAttributes[10];

        ibLogin.ImageUrl = "~/" + swpAttributes[12];
        ibRegister.ImageUrl = "~/" + swpAttributes[13];

        //aforget.HRef = "~/" + swpAttributes[14];
        //tdforget.Attributes.Add("class", swpAttributes[11]);
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        Initlayout();
    }

    /// <summary>
    /// 登陆
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ibLogin_Click(object sender, ImageClickEventArgs e)
    {
        string ReturnDescription = "";

        int Result = new Login().LoginSubmit(this.Page, _Site, txtUserName.Text, txtPassword.Text, txtCode.Text, ref ReturnDescription);

        if (Result < 0)
        {
            Shove._Web.JavaScript.Alert(this.Page, ReturnDescription);

            return;
        }

        new Login().GoToRequestLoginPage("Default.aspx?PN=member_home");        
    }

    /// <summary>
    /// 注册
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ibRegister_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("Default.aspx?PN=register");
    }
}
